/**

 */
package com.adkfp.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.adkfp.bean.ADKManagePageBean;
import com.adkfp.service.IADKManagePageService;
import com.alibaba.fastjson.JSONArray;

/**
 * class name:SelectclassAction <BR>
 * class description: please write your description <BR>
 * Remark: <BR>
 * @version 1.00 2019年1月30日
 * @author ADK)zhoulin
 */
@Controller
@RequestMapping(value="aDKManagePage")
public class ADKManagePageAction {
	
	@Resource(name="aDKManagePageService")
	private IADKManagePageService aDKManagePageService;
	
	/**
	 * 跳转到页面管理页面
	 */
	@RequestMapping(value="pageList")
	public String pageList(HttpServletRequest request){
		
		List<ADKManagePageBean> pageList = aDKManagePageService.getAllManagePage();
		
		request.setAttribute("pageList", JSONArray.toJSON(pageList));
				
		return "manage/pageList";
	}
	
	/**
	 * 增加页面
	 */
	@RequestMapping(value="addManagePage")
	@ResponseBody
	public Object addManagePage(ADKManagePageBean managePageBean){
		
		aDKManagePageService.addManagePage(managePageBean);
		
		return managePageBean;
	}
	
	/**
	 * 删除页面
	 */
	@RequestMapping(value="delManagePageById")
	@ResponseBody
	public String delManagePageById(long id){
		
		try {
			aDKManagePageService.delManagePageById(id);
			
			return "OK";
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "ERROR";
	}
	
	/**
	 * 升级页面, name, url, levelType
	 */
	@RequestMapping(value="updateManagePageById")
	@ResponseBody
	public String updateManagePageById(ADKManagePageBean managePageBean){
		
		try {
			aDKManagePageService.updateManagePageById(managePageBean);
			
			return "OK";
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "ERROR";
	}

}
